<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!-- jqgrid-->
<link
	href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css"
	rel="stylesheet" />
<!doctype html>
<html>
<head>
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
	font-size: 12px;
}

.laydate-icon {
	height: 20px;
}
</style>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;贷中业务>银行资料登记</span>
			<a href="javascript:void(0)"></a>
		</div>
		<div class="buttonfixed">
			<button id="btnsave" class="btn dpbtn_blue btnaplly" type="button"
				onclick="save();">保存</button>
			<button id="btnupdate" class="btn dpbtn_blue btnaplly" type="button"
				onclick="update();">修改</button>
		</div>
		<%@include file="/jsp/comm_yw_info_include.jsp"%>
		<form class="form-horizontal" id="commentForm">
			<div class="business-manwife">银行信息录入</div>
			<input type="hidden" id="middleBankId" />
			<div class="padding-nono">
				<table cellpadding="0" cellspacing="0" border="0"
					class="buyinfor-table">
					<tr>
						<td align="right"><label class="control-label np">银行合同编号：</label>
						</td>
						<td><input class="form-control" 
							type="text" id="contractNo" name="contractNo"
							placeholder="合同编号" /></td>
						<td align="right"><label class="control-label np">还款卡号：</label>
						</td>
						<td><input class="form-control" type="text"
							 id="cardnoRefund" name="cardnoRefund"
							placeholder="还款卡号" /></td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">开卡收到时间：</label>
						</td>
						<td><input id="timeReceiveOpencard"
							name="timeReceiveOpencard" 
							placeholder="时间" class="laydate-icon form-control" /></td>

						<td align="right"><label class="control-label np">银行收到合同时间：</label>
						</td>
						<td><input id="timeReceiveBank" name="timeReceiveBank"
							placeholder="时间" 
							class="laydate-icon form-control" /></td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">后补资料通知时间：</label>
						</td>
						<td><input id="timeSubsequentInform"
							name="timeSubsequentInform" placeholder="通知时间"
							 class="laydate-icon form-control" /></td>

						<td align="right"><label class="control-label np">后补资料收到时间：</label>
						</td>
						<td><input id="timeSubsequentReceive"
							name="timeSubsequentReceive" placeholder="收到时间"
							 class="laydate-icon form-control" /></td>
					</tr>
					<tr>
						<td align="right" valign="top"><label
							class="control-label np">后补资料备注：</label></td>
						<td colspan="3"><textarea id="remarkSubsequent" rows=""
								cols="" class="form-control"></textarea></td>
					</tr>
				</table>
			</div>
			<div class="business-manwife">经办信息</div>
			<div class="padding-nono">
				<table cellpadding="0" cellspacing="0" border="0"
					class="buyinfor-table">
					<tr>
						<td align="right"><label class="control-label np">经办人：</label>
						</td>
						<td><input id="jb_name" class="form-control"
							readonly="readonly" value="${current_user_key.uname}" /></td>
						<td align="right"><label class="control-label np">经办时间：</label>
						</td>
						<td><input id="jb_time" class="laydate-icon form-control"
							placeholder="经办时间" /></td>
					</tr>
				</table>
			</div>
		</form>
	</div>


	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>

	<!-- jqGrid -->
	<script type="text/javascript" charset="utf-8"
		src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>

	<!-- layerDate plugin javascript -->
	<script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>

	<!-- custom js -->
	<%@include
		file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>
	<script type="text/javascript"></script>
	<!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
	<script type="text/javascript">
	    $(function(){	
	    	$("#btnsave").show();
	    	$("#btnupdate").hide();
	    	getBankDataInfo();
		});
		
	    jQuery(function($) {
	    	laydate({
		        elem: '#jb_time', 
		        event: 'focus' 
		    });
		    laydate({
		        elem: '#timeSubsequentReceive', 
		        event: 'focus' 
		    });
		    laydate({
		        elem: '#timeSubsequentInform', 
		        event: 'focus' 
		    });
		    laydate({
		        elem: '#timeReceiveOpencard', 
		        event: 'focus' 
		    });
		    laydate({
		        elem: '#timeReceiveBank', 
		        event: 'focus' 
		    });
	    	
	    });
	    var getBankDataInfo=function(){
	    	var data={};
	    	data.busiId=$.getUrlData("busiId");
	    	data.orderSql="created desc";
	    	$.dpAjax({
	    		url:'${basePath}/DzLoanMiddleBankController/list',
	    		data:data,
    			success: function(datas){
	    			  if(datas.flag == "100100")
					  {
	    				  var data=datas.result.rows;
	    				  if(data.length>0){
	    					  $("#btnsave").hide();
	    				    	$("#btnupdate").show();
	    				    	$("#middleBankId").val(data[0].replaceId);
	    					    $("#remarkSubsequent").val(data[0].remarkSubsequent);
	    				    	$("#timeSubsequentInform").val(data[0].timeSubsequentInform);
	    				    	$("#timeReceiveBank").val(data[0].timeReceiveBank);
	    				    	$("#timeReceiveOpencard").val(data[0].timeReceiveOpencard);
	    				    	$("#contractNo").val(data[0].contractNo);
	    				    	$("#cardnoRefund").val(data[0].cardnoRefund);
	    				    	$("#timeSubsequentReceive").val(data[0].timeSubsequentReceive);
	    				    	$("#jb_time").val(data[0].jbDate);
// 	    				    	$("#jb_name").val(data[0].modifierName);
	    				    	$("#jb_name").val('${current_user_key.uname}');
	    				  }
						  layer.msg('执行成功！', {icon: 6});
					  }
					  if(datas.flag == "100200")
	                  {
						  $.fn.showDatas({"datas":datas});
	                	  return;
	                  }
                 }
	    	});
	    }
	    var update=function(){
	    	var data={};
	    	data.id=$("#middleBankId").val();
	    	data.remarkSubsequent=$("#remarkSubsequent").val();
	    	data.timeSubsequentInform=$("#timeSubsequentInform").val();
	    	data.timeReceiveBank=$("#timeReceiveBank").val();
	    	data.timeReceiveOpencard=$("#timeReceiveOpencard").val();
	    	data.contractNo=$("#contractNo").val();
	    	data.cardnoRefund=$("#cardnoRefund").val();
	    	data.timeSubsequentReceive=$("#timeSubsequentReceive").val();
	    	data.jbDate=$("#jb_time").val();
// 		    data.modifierName=$("#jb_name").val();
// 	        data.modifier="${current_user_key.id}";
        	data.busiId= $.getUrlData("busiId");
	    	data.cusId= $.getUrlData("cusId");
	    	$.dpAjax({
	    		url:'${basePath}/DzLoanMiddleBankController/modify',
	    		data:data,
    			success: function(datas){
	    			  if(datas.flag == "100100")
					  {
						  layer.msg('执行成功！', {icon: 6});
					  }
					  if(datas.flag == "100200")
	                  {
						  $.fn.showDatas({"datas":datas});
	                	  return;
	                  }
                 }
	    	});
	    }
	    var save=function(){
	    	var data={};
	    	data.remarkSubsequent=$("#remarkSubsequent").val();
	    	data.timeSubsequentInform=$("#timeSubsequentInform").val();
	    	data.timeReceiveBank=$("#timeReceiveBank").val();
	    	data.timeReceiveOpencard=$("#timeReceiveOpencard").val();
	    	data.contractNo=$("#contractNo").val();
	    	data.cardnoRefund=$("#cardnoRefund").val();
	    	data.timeSubsequentReceive=$("#timeSubsequentReceive").val();
	    	data.jbDate=$("#jb_time").val();
	    	data.creatorName=$("#jb_name").val();
        	data.creator="${current_user_key.id}";
        	data.busiId= $.getUrlData("busiId");
	    	data.cusId= $.getUrlData("cusId");
	    	$.dpAjax({
	    		url:'${basePath}/DzLoanMiddleBankController/save',
	    		data:data,
    			success: function(datas){
	    			  if(datas.flag == "100100")
					  {
	    				  window.location.href="dzLoanMiddleBankList.jsp";
						  layer.msg('执行成功！', {icon: 6});
					  }
					  if(datas.flag == "100200")
	                  {
						  $.fn.showDatas({"datas":datas});
	                	  return;
	                  }
                 }
	    	});
	    }
	    
    </script>
</body>
</html>
